<?php

namespace Liuhelong\LaravelAdmin\Wechat\Actions\WechatOffiaccountUser;

use Encore\Admin\Actions\RowAction;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;

class Remark extends RowAction
{
    public $name = '修改备注';

    public function form()
    {
		$this->text('remark', '备注')->required();
    }
	
	public function handle(Model $model, Request $request)
    {
		$wechat = app('liuhelong_wechat_service');
		try{
			if(!$wechat->handle('user','remark',[$model->openid, $request->remark])){
				throw new \Exception('修改失败！');
			}
					
			return $this->response()->success('绑定成功')->refresh();
		}catch(\Exception $e){
			return $this->response()->error($e->getMessage())->refresh();
		}
    }
}